(import
 (except (rnrs base) map)
 (only (guile)
       lambda* λ
       ;; ports
       current-output-port
       simple-format)
 ;; SRFI 64 - unit testing forms
 (srfi srfi-64)
 ;; SRFI 43 - vector procs
 (srfi srfi-43)
 ;; SRFI 1 - list procs
 (srfi srfi-1)
 ;; custom libs
 (fslib)
 ;; tested module
 (search))


(test-begin "search-test")

(test-group
 "default comparators"

 (test-assert "default-string-comparator - 01"
   (not
    (equal? #f
            (default-string-comparator "I am a happy string!" "happy"))))

 (test-assert "default-string-comparator - 02"
   (not
    (equal? #f
            (default-string-comparator "hsk" "hsk"))))

 (test-assert "default-string-comparator - 03"
   (equal? #f (default-string-comparator "hsk" "hk")))

 (test-assert "default-number-comparator - 01"
   (default-number-comparator 3 3))

 (test-assert "default-number-comparator - 02"
   (default-number-comparator 2 2))

 (test-assert "default-number-comparator - 03"
   (not
    (default-number-comparator 1 3)))

 (test-assert "default-boolean-comparator - 01"
   (default-boolean-comparator #t "true"))

 (test-assert "default-boolean-comparator - 02"
   (default-boolean-comparator #t "#t"))

 (test-assert "default-boolean-comparator - 03"
   (not
    (default-boolean-comparator #t "false")))

 (test-assert "default-boolean-comparator - 04"
   (not
    (default-boolean-comparator #t "#f")))

 (test-assert "default-vector-comparator - 01"
   (default-vector-comparator #("a" "b" "c") "a"))

 (test-assert "default-vector-comparator - 02"
   (default-vector-comparator #("a" "b" "c") "c"))

 (test-assert "default-vector-comparator - 03"
   (default-vector-comparator #(#t #t #f) #f))

 (test-assert "default-vector-comparator - 04"
   (default-vector-comparator #(1 2 3) 2))

 (test-assert "default-vector-comparator - 05"
   (not
    (default-vector-comparator #(1 2 3) 4)))

 (test-assert "default-vector-comparator - 06"
   (not
    (default-vector-comparator #(#f #f #f) #t)))

 (test-assert "default-vector-comparator - 07"
   (not
    (default-vector-comparator #("a" "b" "c") "d")))

 (test-assert "make-general-comparator - 01"
   ((make-general-comparator) #(1 2 3) 2))

 (test-assert "make-general-comparator - 02"
   ((make-general-comparator) "a b c" "b"))

 (test-assert "make-general-comparator - 03"
   ((make-general-comparator) "a" "a"))

 (test-assert "make-general-comparator - 04"
   ((make-general-comparator) 3 3))

 (test-assert "make-general-comparator - 05"
   ((make-general-comparator) #(1 2 3) 2))

 (test-assert "make-general-comparator - 06"
   ((make-general-comparator) #(#f #t #f) #t))

 (test-assert "make-general-comparator - 07"
   (not
    ((make-general-comparator) #(#f #f #f) #t)))

 (test-assert "make-general-comparator - 08"
   (not
    ((make-general-comparator) #(1 2 3) 4)))

 (test-assert "make-general-comparator - 09"
   (not
    ((make-general-comparator) "hello world" "hallo")))

 (test-assert "make-general-comparator - 10"
   ((make-general-comparator) 1 "1"))

 (test-assert "default-fallback-comparator - 01"
   (default-fallback-comparator "hsk1" "hsk1"))

 (test-assert "default-fallback-comparator - 02"
   (default-fallback-comparator 1 1))

 (test-assert "default-fallback-comparator - 02"
   (default-fallback-comparator 2 2))

 (test-assert "default-fallback-comparator - 03"
   (not
    (default-fallback-comparator #(1 2) #(1 3)))))

;; Finish the testsuite, and report results.
(test-end "search-test")
